﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Hangjing.Model;
using Hangjing.SQLServerDAL;
using Hangjing.Common;

namespace Html5
{
    public partial class selfdispatchh5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UserHelp.IsLogin_Togo(Request.Url.PathAndQuery);
            int pageindex = HjNetHelper.GetQueryInt("PageNo", 1);

            PointsInfo user = UserHelp.GetUser_Togo();
            string sql = "  1=1" ;
            PointsInfo shop = UserHelp.GetUser_Togo();
            if (shop.cityid > 0)
            {
                sql += " and Inve1 = " + shop.cityid;
            }
            if (shop.IsCallCenter > 0)
            {
                sql += " and GpsIMEI = " + shop.IsCallCenter;
            }
            hfgid.Value = shop.IsCallCenter.ToString();


            string url = "selfdispatchh5.aspx?a=1";
            string key = HjNetHelper.GetQueryString("key");
            if (key.Length > 0)
            {
                sql += " AND (name LIKE '%" + key + "%' OR Phone LIKE '%" + key + "%')";
                url += "&key=" + key;
            }

            int state = HjNetHelper.GetQueryInt("state", -1);
            if (state >= 0)
            {
                sql += " and workstate=" + state;
                url += "&state=" + state;
            }

            string lat = HjNetHelper.GetQueryString("lat");
            string lng = HjNetHelper.GetQueryString("lng");
            string orderid = HjNetHelper.GetQueryString("id");


            WebUtility.BindRepeater(rptorder, new Deliver().shopgetDelivers(lat, lng, sql));

            if (rptorder.Items.Count <= 0)
            {
                WebUtility.excutesql("UPDATE dbo.Custorder SET ReveVar1 = '0' WHERE orderid = '" + orderid + "'");
            }

            hfcityid.Value = UserHelp.GetUser_Togo().cityid.ToString(); ;


        }
    }
}
